package cn.edu.neu.lab603.cloudeval.strategy.policy

import java.util.Random

import cn.edu.neu.lab603.cloudeval.entity.{DataCenter, PhysicalMachine => Host, VirtualMachine => VM}

/** 随机选择策略。
  *
  * Created by yfwz100 on 2016/11/9.
  */
class VMSelectionPolicyRandomSelection extends VMSelectionPolicy {

  import MigrationDef._

  override def getVMFromMigratedHost(host: Host)(implicit dataCenter: DataCenter): Iterable[VM] = {
    val vms = host.getMigratableVMs
    if (vms.nonEmpty)
      Seq(vms((new Random).nextInt(vms.size)))
    else
      Seq.empty
  }

  override def toString: String = "RS"
}
